<!-- Copyright 2017 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.bundle.min.js"></script>
<link rel="import" href="../node_modules/@bower_components/polymer/polymer.html">
<link rel="import" href="../node_modules/@bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../node_modules/@bower_components/paper-listbox/paper-listbox.html">
<link rel="import" href="../node_modules/@bower_components/paper-item/paper-item.html">

<dom-module id="math-benchmark">
<style>
  .run-header {
    margin: 12px 0;
  }
  .run-test .run-stop, .run-group-name {
    display: inline-block;
    margin-right: 10px;
  }
  .run-plot {
    display: none;
  }
  .run-numbers-table, .run-plot-container {
    display: inline-block;
    vertical-align: middle;
  }
  .run-numbers-row {
    display: table-row;
  }
  .run-numbers-cell {
    display: table-cell;
    font-size: 12px;
    padding: 0 5px;
  }
  .container {
    margin-top: 20px;
    margin-left: 20px;
  }
  .header {
    font-size: 24px;
  }
  .subheader {
    margin: 12px 0;
    font-size: 15px;
  }
  .run-test, .run-stop {
    margin-right: 12px;
  }
  .math-test {
    margin: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, .2);
  }
  .math-tests {
    margin-top: 28px;
  }
  .run-group-name {
    font-size: 17px;
  }
  .run-message {
    font-style: italic;
  }
  .params {
    font-family: monospace;
    font-size: 10px;
  }
</style>

<template>
<div class="container">
  <div class="header">Benchmarks</div>
  <div class="subheader">Values are averaged over many examples. See JavaScript console for streamed results.</div>
  <div class="math-tests">
    <template is="dom-repeat" items="[[benchmarks]]" as="benchmark">
      <div class="math-test">
        <div class="run-group-name">[[benchmark.name]]</div>
        <div class="params">[[getDisplayParams(benchmark.params, benchmark.selectedOption)]]</div>
        <paper-dropdown-menu no-animations label="Op type" id="options" hidden="[[!benchmark.options]]">
          <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{benchmark.selectedOption}}" slot="dropdown-content">
            <template is="dom-repeat" items="[[benchmark.options]]">
              <paper-item  value="[[item]]" label="[[item]]">
                [[item]]
              </paper-item>
            </template>
          </paper-listbox>
        </paper-dropdown-menu>

        <div class="run-header">
          <button class="run-test mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">Run</button>
          <button class="run-stop mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">Stop</button>
        </div>
        <div class="run-body">
          <div class="run-message" style="display: none">Running, be patient...</div>
          <div class="run-numbers-table"></div>
          <div class="run-plot-container">
            <canvas class="run-plot" width="360" height="270"></canvas>
          </div>
        </div>
      </div>
    </template>
  </div>
</div>
</template>
</dom-module>

